package com.lemner.www.hongyu.Activity;

import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.lemner.www.hongyu.Bean.UnfinishorderBean;
import com.lemner.www.hongyu.Fragement.DingdanFragment;
import com.lemner.www.hongyu.R;

import java.util.ArrayList;
import java.util.List;

public class DingdanActivity extends AppCompatActivity {
  private ViewPager vp;
    private List<Fragment> listfragment;
    private FragmentPagerAdapter fpadapter;
    private DingdanFragment dingdanFragment=new DingdanFragment();
    private int workerid;
    private  int ids;
    private  Bundle bundle;
    private boolean flag;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dingdan);
        workerid=getIntent().getIntExtra("workerid",1);
        ids=getIntent().getIntExtra("ids",1);
        flag=getIntent().getBooleanExtra("frxx",false);
        InitView();
        initFragment();
    }
    public  void InitView(){
        vp=(ViewPager) findViewById(R.id.dingdan);
    }
    private void initFragment() {
        Bundle bundle=new Bundle();
        bundle.putInt("workerid",workerid);
        bundle.putInt("ids",ids);
        bundle.putBoolean("frxx",flag);
        listfragment = new ArrayList<Fragment>();
        listfragment.add(dingdanFragment);
        dingdanFragment.setArguments(bundle);
        fpadapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public int getCount() {
                return listfragment.size();
            }
            @Override
            public Fragment getItem(int position) {
                return listfragment.get(position);
            }
        };
        vp.setAdapter(fpadapter);
        vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            }
            @Override
            public void onPageSelected(int position) {
                vp.setCurrentItem(position);
            }
            @Override
            public void onPageScrollStateChanged(int state) {
            }
        });

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

    }
}
